<header id="topbar" class="affix">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="<%= window.location.href %>">系统通知详情</a>
            </li>
            <li class="crumb-link">
                <a href="#op/notify/">系统通知管理</a>
            </li>
            <li class="crumb-trail">编辑</li>
        </ol>
    </div>
    <div class="pull-right">
        <a href="javascript:;" class="btn btn-primary btn-sm light fw600 ml10" id="save"><span class="fa fa-save"></span>保存</a>
    </div>
</header>
<section id="content">
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
            </span>
            <span class="panel-title">参数设置</span>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" id="content-form">
                <div class="form-group">
                    <label for="inputTitle" class="col-md-1 control-label">标题:</label>
                    <div class="col-md-9">
                        <input type="text" id="inputTitle" class="form-control" placeholder="通知标题" data-field="content.title" required value="<%= info.content.title %>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputTag" class="col-md-1 control-label">tag：</label>
                    <div class="col-md-9">
                        <input id="inputTag" type="text" class="form-control" placeholder="通知tag" data-field="content.tag" required value="<%= info.content.tag %>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputContent" class="col-md-1 control-label">内容:</label>
                    <div class="col-md-9">
                        <textarea id="inputContent" class="form-control" rows="5" placeholder="通知内容..." data-field="content.content"><%= info.content.content %></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputStatus" class="col-md-1 control-label">状态:</label>
                    <div class="col-md-1">
                        <% if(info.status == 0) {%>
                            <select class="form-control" id="inputStatus" data-field="status" data-type="int">
                                <% _.each(NOTIFY_STATUS, function(v, k){ %>
                                    <option value="<%= k %>" <%= info.status == k ? "selected" : "" %>><%= v %></option>
                                <% }) %>
                            </select>
                        <% }else{ %>
                            <p class="form-control-static text-muted"><%= NOTIFY_STATUS[info.status] %></p>
                        <% } %>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputExpireTs" class="col-md-1 control-label">过期时间：</label>
                    <div class="col-md-1">
                        <% var moment = require('moment'); %>
                        <input type="text" class="form-control" data-field="expire_ts"
                         value="<%= info.expire_ts ? moment.unix(info.expire_ts).format('YYYY-MM-DD') : '' %>" id="inputExpireTs" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">命令：</label>
                    <div class="col-md-4">
                        <input type="text" class="form-control" value="<%= info.command %>" data-field="command" data-useless="">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">通知类型:</label>
                    <div class="col-md-4">
                        <select class="form-control" id="inputNotifyType" data-field="notify_type" data-type="int">
                            <% _.each(NOTIFY_TYPE, function(v,k){ %>
                            <option value="<%= k %>" <%= info.notify_type == k ? "selected" : "" %> > <%= v %> </option>
                            <% }) %>
                        </select>
                    </div>
                </div>
            </form>
        </div>
    </div>
        <div class="panel">
            <div class="panel-heading">
                <span class="panel-icon"><i class="fa fa-gear text-primary"></i>
                </span>
                <span class="panel-title">发布对象</span>
                <span class="panel-controls">
                    <a href="#" class="fa fa-plus pt5" id="addFilter"></a>
                </span>
            </div>
            <div class="panel-body">
                <form class="form-horizontal" id="filter-form">
                    <% _.each(info.extend.filter_list || [], function(filter){ %>
                        <div class="form-group filter">
                            <div class="col-md-5 col-md-offset-1">
                                <div class="input-group">
                                    <div class="input-group-btn">
                                        <% var key = filter.chn.exclude ? "exclude" : "include",
                                               values = filter.chn[key],
                                               keyStr = (key == "exclude" ? "排除渠道" : "包含渠道"); %>
                                        <button type="button" class="btn btn-default switch-key" data-key="<%= key %>"><%= keyStr %></button>
                                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ><span class="caret"></span></button>
                                        <ul class="dropdown-menu">
                                            <li><a href="#" class="shortcut" data-aria="allAndroid">全部Android</a></li>
                                            <li><a href="#" class="shortcut" data-aria="allIOS">全部IOS</a></li>
                                        </ul>
                                    </div>
                                    <input type="text" class="form-control filter-value" value="<%= values.join(',') %>" placeholder="以英文逗号分割">
                                </div>
                            </div>
                            <div class="col-md-2">
                                <input type="number" min=1 value="<%= filter.cvc.min || 1 %>" class="form-control" data-field="cvc.min" data-type="int" placeholder="最小版本(含)">
                            </div>
                            <div class="col-md-2">
                                <input type="number" min=1 value="<%= filter.cvc.max  %>" class="form-control" data-field="cvc.max" data-type="int" data-useless="" placeholder="最大版本(含)">
                            </div>
                            <div class="col-md-1">
                                <button class="btn btn-danger remove-filter">删除该项</button>
                            </div>
                        </div>
                    <% }) %>
                </form>
            </div>
        </div>
</section>

<div class="placeholder" id="filterTemplate" hidden>
    <div class="form-group filter">
        <div class="col-md-5 col-md-offset-1">
            <div class="input-group">
                <div class="input-group-btn">
                    <button type="button" class="btn btn-default switch-key" data-key="include">包含渠道</button>
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" ><span class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li><a href="#" class="shortcut" data-aria="allAndroid">全部Android</a></li>
                        <li><a href="#" class="shortcut" data-aria="allIOS">全部IOS</a></li>
                    </ul>
                </div>
                <input type="text" class="form-control filter-value" value="" placeholder="以英文逗号分割">
            </div>
        </div>
        <div class="col-md-2">
            <input type="number" min=1 value="1" class="form-control" placeholder="最小版本(含)" data-field="cvc.min" data-type="int">
        </div>
        <div class="col-md-2">
            <input type="number" min=1 value="" class="form-control" placeholder="最大版本(含)" data-field="cvc.max" data-type="int" data-useless="">
        </div>
        <div class="col-md-1">
            <button class="btn btn-danger remove-filter">删除该项</button>
        </div>
    </div>
</div>